﻿using System;
using System.Collections.Generic;
using SimpleInjector;
using IDependencyResolver = System.Web.Mvc.IDependencyResolver;

namespace YetAnotherChat.BackendCore.Injector
{
    public class SimpleInjectorDependencyResolver : IDependencyResolver
    {
        public readonly Container Container;

        public SimpleInjectorDependencyResolver(Container container)
        {
            Container = container;
        }

        public object GetService(Type serviceType)
        {
            return ((IServiceProvider)Container).GetService(serviceType);
        }

        public IEnumerable<object> GetServices(Type serviceType)
        {
            return Container.GetAllInstances(serviceType);
        }
    }
}